<template>
    <div class="ma-content-block p-4">
        <a-form ref="formRef" auto-label-width :model="form" @submit="handleSubmit">
            <a-divider orientation="left">众筹佣金</a-divider>
            <a-form-item :field="item.key" :label="item.name" label-col-flex="auto" :label-col-style="{ width: '85px' }"
                v-for="item in list">
                <a-input v-model="form[item.key]" :placeholder="`请输入${item.name}`"></a-input>
            </a-form-item>
            <a-divider orientation="left">众筹佣金</a-divider>
            <a-form-item :field="item.key" :label="item.name" label-col-flex="auto" :label-col-style="{ width: '85px' }"
                v-for="item in data">
                <a-input v-model="form[item.key]" :placeholder="`请输入${item.name}`"></a-input>
            </a-form-item>
            <a-divider orientation="left">C2C佣金</a-divider>
            <a-form-item field="c2c_commission" label="C2C佣金" label-col-flex="auto"
                :label-col-style="{ width: '85px' }">
                <a-input v-model="form.c2c_commission" placeholder="请输入C2C佣金"></a-input>
            </a-form-item>
            <a-form-item>
                <a-button type="primary" style="margin-right:20px;" html-type="submit">立即提交</a-button>
                <a-button type="outline" @click="$refs.formRef.resetFields()">重置</a-button>
            </a-form-item>
        </a-form>
    </div>
</template>

<script setup>
import request from "@/api/base/setting";
import { Message } from "@arco-design/web-vue";
import { ref } from "vue";
const form = ref({
    key: "commission"
});

const list = [
    { key: "raise_one", name: "一级" },
    { key: "raise_two", name: "二级" },
    { key: "raise_three", name: "三级" },
    { key: "raise_four", name: "四级" },
    { key: "raise_five", name: "五级" },
    { key: "raise_sex", name: "六级" },
    { key: "raise_seven", name: "七级" },
    { key: "raise_eight", name: "八级" },
    { key: "raise_nine", name: "九级" }
];

const data = [
    { key: "one_one", name: "一级" },
    { key: "one_two", name: "二级" },
    { key: "one_three", name: "三级" },
    { key: "one_four", name: "四级" },
    { key: "one_five", name: "五级" },
    { key: "one_sex", name: "六级" },
    { key: "one_seven", name: "七级" },
    { key: "one_eight", name: "八级" },
    { key: "one_nine", name: "九级" }
];

const get_list = async () => {
    let { data } = await request.get_deta({
        key: form.value.key
    });
    data? form.value = data : "";
};
get_list();

const handleSubmit = async () => {
    await request.save(form.value);
    Message.success("保存成功");
};
</script>
